package view.component.window
{
import core.Language;

import framework.view.components.button.ButtonProxy;

import mapengine.interfaces.IFactoryBuilding;

import mx.utils.StringUtil;

import values.item.building.FactoryBuildingItemTemplateValue;


/**
 * UpgradeFactoryBuildingUIProxy
 * @author jliang
 *
 */
public class UpgradeFactoryBuildingUIProxy extends UpgradeBuildingUIProxy
{
	//==========================================================================
	//  Constructor
	//==========================================================================
	public function UpgradeFactoryBuildingUIProxy()
	{
		super();
	}
	//==========================================================================
	//  Properties
	//==========================================================================
	protected function get finishProduceBtn():ButtonProxy
	{
		return proxys["finishProduceBtn"];
	}
	//==========================================================================
	//  Overridden methods: UpgradeBuildingUIProxy
	//==========================================================================
	override protected function get proxyMapping():Array
	{
		return [ 
			{ skin:"finishProduceBtn", classRef: ButtonProxy, id:"finishProduceBtn", text:Language.getText("@upgrade_building_finish_produce_button_label"), onClick: onClickToFinishProduceHandler }
		].concat(super.proxyMapping);
	}	
	
	override protected function init():void
	{
		super.init();
		
		var factoryTemplate:FactoryBuildingItemTemplateValue = IFactoryBuilding(data).factoryBuildingItemValue.factoryBuildingTemplate;
		
		var currentPlus:Number = factoryTemplate.getBonusPlusByLevel(data.buildingItemValue.level);
		var nextPlus:Number = factoryTemplate.getBonusPlusByLevel(data.buildingItemValue.level + 1);
		
		skin.currentPlusLabel.text = StringUtil.substitute(Language.getText("@factory_upgrade_plus_label"), int(currentPlus * 100));
		skin.nextPlusLabel.text = StringUtil.substitute(Language.getText("@factory_upgrade_plus_label"), int(nextPlus * 100));
		
		if (IFactoryBuilding(data).isWaitingProduce)
		{
			skin.infoLabel.visible = finishProduceBtn.visible = finishProduceBtn.enabled = false;
		}
	}
	//==========================================================================
	//  Event handlers
	//==========================================================================
	protected function onClickToFinishProduceHandler():void
	{
		
	}
	
}
}




